var isLogin = function () { let result; eAjax.get({ url: "/login/check", method: "GET", async: false , dataType: "json", contentType: 'application/json;charset=utf-8' }).done(function(response) { if(response.resultCode == '200') { result = response.data; } }); return result; }; var loginMenu = { $el: (function () { return $('[data-login-menulist]'); })(), active: function () { var $el = this.$el; var childs = $el.find('[data-menu-login]'); childs.remove(); var layouts = (function () { var r = []; r.push('
  • 로그아웃
  • '); return r.join(''); })(); $el.prepend(layouts); }, deactive: function () { var $el = this.$el; var childs = $el.find('[data-menu-logout]'); childs.remove(); var layouts = (function () { var r = []; r.push('
  • 로그인
  • '); r.push('
  • 회원가입
  • '); return r.join(''); })(); $el.prepend(layouts); } }; function getLoginPromiseData(type) { switch (type) { case "report": return '{"callback":"ReportLogicFunc"}'; case "recommend": return '{"callback":"RecommendLogicFunc"}'; case "rewhsin": return '{"callback":"AddReinLayerOpen"}'; case "coupon": return '{"callback":"AddCouponDown"}'; default: return ""; } } function replaceHtmlEntity(entity) { switch (Object.prototype.toString.call(entity).slice(8, -1)) { case 'Object': for (let key in entity) { let newKey = key; entity[newKey] = replaceHtmlEntity(entity[newKey]); } return entity; case 'Array': return entity.map(e => replaceHtmlEntity(e)); case 'String': return replaceNamedCharacterToGlyph(entity); default : return entity; } } function replaceNamedCharacterToGlyph(entity) { return !entity ? '' : entity.replaceAll('&', '&') .replaceAll('<', '<') .replaceAll('<', '<') .replaceAll('>', '>') .replaceAll('"', '"') .replaceAll('·', '·') .replaceAll(' ', ' ') .replaceAll('’', '’') .replaceAll('‘', '‘') .replaceAll('“', '“') .replaceAll('”', '”') .replaceAll('♥', '♥') .replaceAll('×', '×') .replaceAll('♣', '♣') .replaceAll('♠', '♠') .replaceAll('♦', '♦') .replaceAll('★', '★') .replaceAll('☆', '☆') .replaceAll('™', '™') .replaceAll('®', '®') .replaceAll('©', '©') .replaceAll('✓', '✓') .replaceAll('✗', '✗') .replaceAll('♪', '♪') .replaceAll('@', '@'); } (function (isUndefined) { var win = window; var vt = gUtil.validator; var validateMethod = { dataAttr: { cp: 'data-cnr-no', }, getPageId: function () { return vt.store({ getScopeChaningEnd: function () { return ['TuhoClient', 'getPageId'] }, }, ''); }, getCornerNo: function (target) { var dataAttr = this.dataAttr; var cornerEl = target.closest('['+dataAttr.cp+']'); return cornerEl.length ? $.trim(cornerEl.attr(dataAttr.cp)) : null; }, getTuhoData: function (url, data) { var Util = win.EB.util; var _url = url; var _data = gUtil.def({}, data); if (_data.e != isUndefined) { var $t = $(_data.e.currentTarget); if ($t.length) { var corner_no = this.getCornerNo($t); var page_id = this.getPageId(); if (corner_no != null) { var _pathData = Util.location._getPathData('preCornerNo', corner_no, _url); _url = Util.location._getFullUrl(_pathData, _url); } if (page_id.length) { var _pathData = Util.location._getPathData('pageId', page_id, _url); _url = Util.location._getFullUrl(_pathData, _url); } } delete _data.e; } return { url: _url, data: _data, }; } }; window.validateMethod = validateMethod; })(); (function () { window.postSendForm = function (url, data) { var f=document.createElement('form'); f.setAttribute('method','post'); var getTuhoData = window.validateMethod.getTuhoData(url, data); var _url = getTuhoData.url; var _data = getTuhoData.data; f.setAttribute('action',_url); document.body.appendChild(f); var $f = $(f); var layouts = (function () { var r = []; for(var key in _data){ r.push(""); } return r.join(''); })(); $f.append(layouts); f.submit(); }; })(); (function () { window.getSendForm = function (url, data) { var f=document.createElement('form'); f.setAttribute('method','get'); f.setAttribute('action',url); document.body.appendChild(f); var $f = $(f); var layouts = (function () { var r = []; for(var key in data){ r.push(""); } return r.join(''); })(); $f.append(layouts); f.submit(); }; })(); (function (isUndefined) { var win = window; var doc = win.document; var gUtil = win.gUtil; var isAndroid = gUtil.Device.android; // isAndroid = true; // 에뮬레이터에서 test window.SWIPEHOME = { loaded: false, scrollName: 'preScroll', loadScroll: null, params: { activeData: {}, loadData: {} }, domstate: { load1: false }, actionType: {}, /* ####DATA#### */ // 스와이프홈 tuho 전송을 위한 함수 sendLogToTopic: function (props) { if (window.TuhoClient != isUndefined) { var param = gUtil.def(props, this.actionType); TuhoClient.sendLogToTopic('tracking', param); this.actionType = {}; } }, mktTracking: function (val, val2) { if (window.swipe_tracking != isUndefined) { swipe_tracking(val, val2); } }, flickChangeData: {}, buildFlick: function () { var $obj = $('[data-flick="region"]'); var instance = $obj.data('CmFlick'); if (instance != isUndefined) { instance.on('changeStart', function (props) { if (props.center.name != '/h/main') { this.mainlayer.destroy(); } }.bind(this)); instance.on('changeEnd', function (props) { this.flickChangeData = props; if (props.hasOwnProperty('action')) { this.actionType['adhoc_swipe_action'] = props.action; } if (props.center.name != '/h/main') { this.mainlayer.destroy(); } }.bind(this)); } }, buildMainNoticeLayer: function () { gUtil.def(this, { mainlayer: { instance: null, destroy: function () { if (this.instance == null) return; this.instance.destroy(); $('#MainNoticeWrapper').empty(); this.instance = null; }, build: function () { if (this.instance != null) return; this.instance = new mainNoticeLayer({ appendContainer: $('#MainNoticeWrapper') }); } } }); }, winSize: (function () { return function () { var win_wh = { w: win.innerWidth || doc.documentElement.clientWidth || doc.body.clientWidth, h: win.innerHeight || doc.documentElement.clientHeight || doc.body.clientHeight }; return win_wh; } })(), loadToScroll: function (prop) { if (this.loadScroll != null) { var isKidiKidi = (function () { var r = false; if (win.UIPage && (win.UIPage.dispMallNo == '0000113')) { r = true; } return r; })(); var _scroll = parseFloat(this.loadScroll); if (isKidiKidi && (prop.name === '/p/main')) { _scroll = (this.winSize().h / 2); } var timeToScroll = function () { win.setTimeout(function () { $(window).scrollTop(_scroll); }, 10); }; if (prop.type === 'load') { timeToScroll(); } else { $(win).on('load', function () { timeToScroll(); }); } this.loadScroll = null; } }, activate: function (prop) { this.params.activeData = prop; if (!this.loaded) { this.loadToScroll({ type: 'swipe', name: prop.name, }); } this.loaded = true; if ((this.flickChangeData.center.name == '/h/main') && (prop.name == '/h/main')) { this.mainlayer.build(); } else { this.mainlayer.destroy(); } this.activateTuho(prop); }, beforeDestroy: function (prop) { if (prop.name == '/h/main') { this.mainlayer.destroy(); } }, /* ####DATA#### */ // 스와이프홈일 때 ajax data를 가져와서 넣어주는 함수 // 실제로 서버에 보내는 함수 activateTuho: function (prop) { var _title = prop.title; var $target = prop.$target; var $inpPageNo = $target.find('input[name="swipe_pageno"]'); var $inpTracking = $target.find('input[name="swipe_tracking"]'); this.sendLogToTopic({ pageNo: $inpPageNo.val() }); this.mktTracking($inpTracking.val(), _title); }, getURL: function (type) { var scrollName = this.scrollName; var realState = null; var location = window.location; var href = location.href; var aSearch = href.split('?'); var pathname = aSearch[0]; var search = aSearch[1]; var aOnlySearch = []; var hashStr = ''; if (search != isUndefined) { var aHash = search.split('#'); var onlySearch = aHash[0]; hashStr = aHash[1] == isUndefined ? '' : '#' + aHash[1]; aOnlySearch = onlySearch.length ? onlySearch.split('&') : []; } if (type == 'remove') { var hasIdx = null; aOnlySearch.forEach(function (val, idx) { var option = val, keyVals = option.split('='), key = keyVals[0].replace('?', ''); if (scrollName == key) { hasIdx = idx; } }); if (hasIdx != null) { aOnlySearch.splice(hasIdx, 1); } } else { var hasScroll = false; var scrollY = window.scrollY; aOnlySearch.forEach(function (val, idx) { var option = val, keyVals = option.split('='), key = keyVals[0].replace('?', ''); if (scrollName == key) { hasScroll = true; aOnlySearch[idx] = key + '=' + scrollY; } }); if (!hasScroll) { aOnlySearch.push(scrollName + '=' + scrollY); } } realState = pathname + '?' + aOnlySearch.join('&') + hashStr; return realState; }, addScrollPosition: function () { if (isAndroid) { var getURL = this.getURL('add'); if (getURL != null) { window.history.replaceState(null, null, getURL); } } }, /* ####DATA#### */ // tuho를 실행할 함수에 대한 이벤트 바인딩 // APP, Mobible은 싱글페이지앱이라 기본 뼈대만 있고 컨텐츠들은 ajax를 통해 불러온다. // 그렇기 때문에 스와이프홈에서는 별도의 이벤트바인딩이 필요하다.(기존 ajax의 데이터로 변환해주어야 한다. ) bindEvents: function () { var pageShowEvent = function () { var params = this.params; var domstate = this.domstate; if (domstate.load1) { domstate.load1 = false; } else { if (params.loadData.hasFlick) { this.activateTuho(params.activeData); } } /* 안드로이드이면서 bfcache가 동작되는 상황일때 window load 가 실행되지 않기 때문에 ssrLoad 가 실행되지 않음 따라서, 주소에서 scroll 값이 있으면 새로고침할때 계속 해당 스크롤로 이동되기 때문에 scroll 값 삭제 */ if (isAndroid) { this.getScrollToDelParam(); this.loadScroll = null; } }.bind(this); var eventName = window.pageShowTriggerDispathEvent; window.addEventListener(eventName, function (e) { pageShowEvent(); }); /* ####DATA#### */ // APP andriod 의 경우 상품상세에서 새창열기를 하기 때문에 // 뒤로가기시 히스토리백이 안되 데이터 수집이 안된다. // 해당 케이스를 해결하기 위한 이벤트 바인딩 작업 // 환님 작업 var event; // The custom event that will be created if(document.createEvent){ event = document.createEvent("HTMLEvents"); event.initEvent(eventName, true, true); event.eventName = eventName; } else { event = document.createEventObject(); event.eventName = eventName; event.eventType = eventName; } $(window).on('pageshow', function () { pageShowEvent(); }); $(window).on('pagehide', this.addScrollPosition.bind(this)); }, getScrollToDelParam: function () { var scrollName = this.scrollName; var search = window.location.search; var aOnlySearch = []; if (search.length) { var aHash = search.split('#'); var onlySearch = aHash[0]; aOnlySearch = onlySearch.length ? onlySearch.split('&') : []; } var scrollY = null; aOnlySearch.forEach(function (val, idx) { var option = val, keyVals = option.split('='), key = keyVals[0].replace('?', ''); if (scrollName == key) { scrollY = keyVals[1]; } }); if (scrollY != null) { var getURL = this.getURL('remove'); if (getURL != null) { window.history.replaceState(null, null, getURL); } } return scrollY; }, ssrLoad: function (prop) { /* 스와이프가 아닌 페이지(server side rendering)일 경우의 안드로이드 뒤로가기 할때 스크롤 위치 안 맞는 이슈 대응 window load 이벤트에서 실행되는 메서드임 */ this.params.loadData = prop; this.domstate.load1 = true; if (!prop.hasFlick) { if (isAndroid) { this.loadToScroll({ type: 'load', name: win.location.pathname, }); } } }, init: function () { // 안드로이드 뒤로가기 할때 스크롤 위치 안 맞는 이슈 대응 if (isAndroid) { var getScrollToDelParam = this.getScrollToDelParam(); this.loadScroll = getScrollToDelParam; } $(function () { window.setTimeout(function () { this.buildFlick(); }.bind(this), 0); }.bind(this)); this.buildMainNoticeLayer(); this.bindEvents(); }, }; window.SWIPEHOME.init(); })(); (function (global, factory) { global = global; global.PageConfig = factory(); }(this, function () { 'use strict'; var Component = (function (isUndefined) { var win = window, $ = win.jQuery, gUtil = win.gUtil; var localStorage = { set: function (name, val) { win.localStorage.setItem(name, val); }, get: function (name) { return win.localStorage.getItem(name); }, remove: function (name) { win.localStorage.removeItem(name); }, clear: function () { win.localStorage.clear(); } }; function Component(args) { var defParams = { pathname: null, multiBrowser: true, // 페이지 2개 띄워놓을 경우 stateAttr: { destroy: false }, storageName: 'PageConfig', }; this.opts = gUtil.def(defParams, (args || {})); this.init(); }; Component.prototype = gUtil.def({ init: function () { this.buildParams(); this.buildFlick(); this.loadComponent(); }, buildParams: function () { var _this = this; gUtil.def(this, { params: { pathname: null, corners: {}, info: {}, history: {}, storage: {}, previousStorage: {}, pageId: (function () { var params = new URLSearchParams(win.location.search); var pageId = params.get('pageId'); if (pageId == null) { var location = win.location; var r = []; r.push(location.origin); r.push(location.pathname); pageId = r.join(''); } return pageId; })(), isCurrentPage: function () { return (this.pathname == _this.opts.pathname); }, getCorner: function (cnrNo) { if (this.corners[cnrNo] == isUndefined) { this.corners[cnrNo] = {}; } return this.corners[cnrNo]; }, storageSave: function () { var _time = (function () { var todayDate = new Date(); var expiredays = 1; todayDate = new Date(parseInt(todayDate.getTime() / 86400000) * 86400000 + 54000000); if (todayDate > new Date()) { expiredays = expiredays - 1; } todayDate.setDate(todayDate.getDate() + expiredays); return todayDate.getTime(); })(); var o = { data: this.storage, _expires: String(_time) }; localStorage.set(_this.opts.storageName, JSON.stringify(o)); }, storageSync: function () { var pathname = this.pathname; var pageId = this.pageId; var storageName = _this.opts.storageName; var getStorage = localStorage.get(storageName); if (getStorage != null) { getStorage = JSON.parse(getStorage); var now = new Date().getTime(); var save = Number(getStorage._expires); if (now >= save) { localStorage.remove(storageName); } else { this.storage = getStorage.data; } } if (this.storage[pageId] == isUndefined) { this.storage[pageId] = {}; } this.history = this.storage[pageId]; if (this.history[pathname] == isUndefined) { this.history[pathname] = {}; } if (this.history[pathname]['corners'] == isUndefined) { this.history[pathname]['corners'] = {}; } if (this.history[pathname]['info'] == isUndefined) { this.history[pathname]['info'] = {}; } this.corners = this.history[pathname]['corners']; this.info = this.history[pathname]['info']; }, build: function () { var $obj = $('[data-flick="region"]'); var instance = $obj.data('CmFlick'); if (instance != isUndefined) { var params = instance.flicktab.params; this.pathname = params.center.name; } else { var pathName = (function () { var getParams = function (str) { var r = {}; if (str != isUndefined) { var aAmp = str.split('&'); aAmp.forEach(function (amp) { var aVal = amp.split('='); if (!r.hasOwnProperty(aVal[0])) { r[aVal[0]] = aVal[1]; } }); } return r; }; var searchPathname = (function () { var pathname = win.location.search; var aPath = pathname.split('?'); return getParams(aPath[1]); })(); var optsPathname = (function () { var pathname = this.opts.pathname; var aPath = pathname.split('?'); return getParams(aPath[1]); }.bind(_this))(); var isValid = true; for (var key in optsPathname) { var _val = optsPathname[key]; if (!searchPathname.hasOwnProperty(key)) { isValid = false; } else if (searchPathname.hasOwnProperty(key) && (searchPathname[key] != _val)) { isValid = false; } } var r = win.location.pathname; if (isValid) { r = _this.opts.pathname; } return r; }.bind(_this))(); this.pathname = pathName; } this.history[this.pathname] = {}; this.storageSync(); gUtil.def(this.previousStorage, this.storage); } } }); this.params.build(); }, buildFlick: function () { var $obj = $('[data-flick="region"]'); var instance = $obj.data('CmFlick'); if (instance != isUndefined) { instance.on('changeEnd', function (props) { this.params.pathname = props.center.name; }.bind(this)); } }, loadComponent: function () { win.setTimeout(function () { if (!this.opts.stateAttr.destroy) { if (this.params.isCurrentPage()) { var corners = this.params.history[this.params.pathname].corners; if (Object.keys(corners).length) { for (var k in corners) { var corner = corners[k]; for (var ck in corner) { this.emit(k + '.' + ck + ':load', corner[ck]); } this.emit(k + ':load', corner); } this.emit('load', corners); } } else { // console.log('현재 페이지 아님', this.emit('load')); } } }.bind(this), 0); }, pageHide: function () { if (this.opts.multiBrowser) { this.params.storageSync(); } var pageId = this.params.pageId; var storage = this.params.storage[pageId]; var history = storage[this.opts.pathname]; if (history != isUndefined) { var corners = history.corners; if (this.params.isCurrentPage() && (pageId != null) && Object.keys(corners).length) { history['info'].scrollX = win.scrollX; history['info'].scrollY = win.scrollY; this.params.storageSave(); } } }, _loadData: {}, load: function (order, params) { var _cnrNo = params.cnrNo; var _name = params.name; var pageId = this.params.pageId; var prevStorage = this.params.previousStorage; var prevHistory = prevStorage[pageId]; var prevCorners = prevHistory[this.params.pathname].corners; var prevTravel = prevCorners[_cnrNo]['travel']; var loaded = this._loadData; for (var cKey in prevCorners) { if (!loaded.hasOwnProperty(cKey)) { loaded[cKey] = {}; } var prevCorner = prevCorners[cKey]['travel']; for (var tKey in prevCorner) { if (!loaded[cKey].hasOwnProperty(tKey)) { loaded[cKey][tKey] = { stack: 0, state: false }; } } } var always = function () { console.log('실행됨'); }.bind(this); var done = function () { var r = true; for (var cKey in loaded) { var cLoaded = loaded[cKey]; for (var key in cLoaded) { if (!cLoaded[key].state) { r = false; } } } if (r) { var _info = this.params.history[this.params.pathname]['info']; console.log('모두 완료', { info: _info, }); } }.bind(this); if (order == 'stack') { loaded[_cnrNo][_name].stack++; always(); if (prevTravel[_name] == loaded[_cnrNo][_name].stack) { loaded[_cnrNo][_name].state = true; done(); } } else { loaded[_cnrNo][_name].state = true; always(); done(); } }, save: function (config, params) { if (this.opts.multiBrowser) { this.params.storageSync(); } var cfKey = config.key; var order = config.type; var _cnrNo = params.cnrNo; var corner = this.params.getCorner(_cnrNo); if (corner[cfKey] == isUndefined) { corner[cfKey] = {}; } var _save = (function () { var _name = params.name; var r = gUtil.def({}, corner[cfKey]); if (order === 'stack') { if (r[_name] == isUndefined) { r[_name] = 0; } r[_name] = r[_name] + 1; } else { r[_name] = params.value; } return r; }.bind(this))(); gUtil.def(corner[cfKey], _save); var pathname = this.params.pathname; if (pathname == this.opts.pathname) { this.params.history[pathname].corners[_cnrNo][cfKey] = corner[cfKey]; this.params.storageSave(); } }, travel: function (order, params) { this.save({ key: 'travel', type: order }, params); }, get: function (props) { var deferred = $.Deferred(); var params = this.params; var history = params.history[params.pathname]; var o = {}; if (history != isUndefined) { if (props == isUndefined) { o = gUtil.def({}, history['corners']); } else { o = gUtil.def({}, history['corners'][props.cnrNo]); } } deferred.resolve(o); return deferred.promise(); }, destroy: function () { this.opts.stateAttr.destroy = true; } }, { subscribers: {}, on: function (event, cb, context) { this.subscribers = $.extend({}, this.subscribers); this.subscribers[event] = this.subscribers[event] || []; this.subscribers[event].push({ callback: cb, context: context }); }, off: function (event, cb, context) { var idx, subs = this.subscribers[event], sub; if (subs) { idx = subs.length - 1; while (idx >= 0) { sub = subs[idx]; if ((sub.callback === cb) && (!context || sub.context === context)) { subs.splice(idx, 1); break; } idx--; } } }, emit: function (event) { var subs = this.subscribers[event], idx = 0, args = Array.prototype.slice.call(arguments, 1), sub; if (subs) { while (idx < subs.length) { sub = subs[idx]; sub.callback.apply(sub.context || this, args); idx++; } } } }); return Component; })(); return Component; })); (function (global, factory) { global = global; global.ePagination = factory(); }(this, function () { 'use strict'; var Component = (function (isUndefined) { var win = window, $ = win.jQuery, Util = { page: { scrollTween: null, scrollTo: function (props) { if (this.scrollTween != null) { this.scrollTween.kill(); this.scrollTween = null; } var speed = 350; var to = 0; if (props != isUndefined && props.speed != isUndefined) { speed = props.speed; } if (props != isUndefined && props.to != isUndefined) { to = props.to; } var prop = { to: $(win).scrollTop() }; this.scrollTween = TweenLite.to(prop, speed / 1000, { to: to, onUpdate: function () { $('html, body').scrollTop(prop.to); } }); } } }; function Component(container, args) { var defParams = { datas: {}, itemNo: null, rangePage: 10, page: 1, size: 20, total: 0 }; this.opts = gUtil.def(defParams, (args || {})); if (!(this.obj = $(container)).length) return; this.init(); }; Component.prototype = { init: function () { this.setElements(); this.buildMakeHtml(); this.buildParams(); this.buildLoader(); this.makehtml.set.pagination({ size: this.opts.size, page: this.opts.page, totalCount: this.opts.total }); this.obj.data('ePagination', this); }, setElements: function () { this.$target = $('[data-epagination-target="' + this.opts.target + '"]'); this.$cmPagination = this.obj; this.$pagingWrap = this.$cmPagination.find('.pagination__inner'); }, buildMakeHtml: function () { var _this = this; gUtil.def(this, { makehtml: { get: { pagination: function (props) { var size = props.size; var page = props.page; var totalCount = props.totalCount; var totalPage = Math.ceil(totalCount / size); var rangePage = _this.opts.rangePage; var min = 1; var max = (min - 1) + rangePage; var rangeHalfPage = Math.floor(rangePage / 2); var minPage = page - rangeHalfPage; if (minPage > 1) { min = minPage; max = (minPage - 1) + rangePage; } if (max > totalPage) { max = totalPage; } if ((minPage > 0) && (max == totalPage)) { min = max - rangePage + 1; if (min < 1) { min = 1; } } var layouts = []; var initMin = min; for (; min <= max; min++) { var activeClass = (min == page) ? ' class="active"' : ''; layouts.push('' + min + ''); } var f = []; var currFirstPage = (parseInt(page/size)*size) + 1 var prevPage = currFirstPage - size; var nextPage = currFirstPage + size; if(initMin > 1) { f.push('첫 페이지로 이동'); f.push('이전 페이지로 이동'); } var l = []; if(totalPage > max) { l.push('다음 페이지로 이동'); l.push('마지막 페이지로 이동'); } layouts.unshift(f.join('')); layouts.push(l.join('')); return layouts.join(''); } }, set: { pagination: function (props) { var totalCount = _this.opts.total; if (totalCount > 0) { var getHtml = _this.makehtml.get.pagination(props); var $getHtml = $(getHtml); _this.$pagingWrap.empty().append($getHtml); _this.$cmPagination.css('display', ''); } else { _this.$cmPagination.hide(); } } } } }); }, buildParams: function () { var _this = this; gUtil.def(this, { params: { searchview: function () { // search var _search = win.location.search; if (_search.length) { var isChanged = false; var sa = _search.split('&'); var pageData = {}; sa.forEach(function (si) { var sa = si.split('='); var sak = sa[0]; if (sak == 'page') { pageData[sak] = sa[1]; } }); if (Object.keys(pageData).length) { isChanged = true; } if (isChanged) { _this.makehtml.set.pagination({ page: pageData['page'], size: _this.opts.size, totalCount: _this.opts.total }); } } }, scrollTo: function ($target) { var winTop = $(win).scrollTop(); var getStickyTopHeight = window.EB.util.page.sticky.getStickyTopHeight($target); var to = $target.length ? $target.offset().top - getStickyTopHeight : null; if (to != null) { if (winTop > to) { Util.page.scrollTo({ to: to, speed: 0 }); } } }, cnrNo: null, pageName: null, init: function () { var $component = _this.obj.closest('.cm-component'); var cnrNo = $component.data('cnr-no'); this.cnrNo = cnrNo; this.pageName = cnrNo + '_paging'; } } }); this.params.init(); }, buildLoader: function () { var $target = this.$target; gUtil.def(this, { loader: { qna: { state: false, instance: null, stack: 0, finish: function () { if (this.instance == null) return; if (this.stack == 0) { this.state = false; this.instance.finish(); this.instance = null; } else { this.stack--; } }, run: function () { this.state = true; if (this.instance == null) { this.instance = new win.CustomLoader($target); } else { this.stack++; } } } } }); }, pagingBtnClick: function (e) { var $t = $(e.currentTarget); this.makehtml.set.pagination({ page: $t.data('value'), size: this.opts.size, totalCount: this.opts.total }); }, pagingFirstClick: function (e) { var $pagingWrap = this.$pagingWrap; var current = $pagingWrap.find('[data-paging-btn].active').data('value'); var target = 1; if (current != target) { this.makehtml.set.pagination({ page: target, size: this.opts.size, totalCount: this.opts.total }); } }, pagingPrevClick: function (e) { var $pagingWrap = this.$pagingWrap; var current = $pagingWrap.find('[data-paging-btn].active').data('value'); var target = current - 1; if (target < 1) { target = 1; } if (current != target) { this.makehtml.set.pagination({ page: target, size: this.opts.size, totalCount: this.opts.total }); } }, pagingNextClick: function (e) { var $pagingWrap = this.$pagingWrap; var totalCount = this.opts.total; var size = this.opts.size; var current = $pagingWrap.find('[data-paging-btn].active').data('value'); var target = current + 1; var totalPage = Math.ceil(totalCount / size); if (target > totalPage) { target = totalPage; } if (current != target) { this.makehtml.set.pagination({ page: target, size: this.opts.size, totalCount: this.opts.total }); } }, pagingLastClick: function (e) { var $pagingWrap = this.$pagingWrap; var totalCount = this.opts.total; var size = this.opts.size; var current = $pagingWrap.find('[data-paging-btn].active').data('value'); var target = Math.ceil(totalCount / size); if (current != target) { this.makehtml.set.pagination({ page: target, size: this.opts.size, totalCount: this.opts.total }); } }, parseData: function (e, props) { var $t = e != null ? $(e.currentTarget) : e; var $pagingWrap = this.$pagingWrap; var totalCount = this.opts.total; if (props.data.hasOwnProperty('size')) { this.opts.size = props.data.size; } var size = this.opts.size; var current = $pagingWrap.find('[data-paging-btn].active').data('value'); var target = null; if ($t != null) { if ($t.data('paging-btn') != isUndefined) { target = $t.data('value'); } else { if ($t.hasClass('btn_paging_first')) { target = 1; } else if ($t.hasClass('btn_paging_prev')) { target = current - 1; if (target < 1) { target = 1; } } else if ($t.hasClass('btn_paging_next')) { target = current + 1; var totalPage = Math.ceil(totalCount / size); if (target > totalPage) { target = totalPage; } } else if ($t.hasClass('btn_paging_last')) { target = Math.ceil(totalCount / size); } } } gUtil.def(props.data, { size: this.opts.size }); if (!props.data.hasOwnProperty('page')) { props.data.page = target; } return props; }, setData: function (props) { var response = props.response; var $response = $(response); var $target = this.$target; this.params.scrollTo($target); $target.empty().append($response); var $totalEl = $target.find('[data-total]'); if ($totalEl.length) { this.opts.total = $totalEl.eq(0).data('total'); } else { this.opts.total = 0; } if (props.hasOwnProperty('e') && (props.e != null)) { var e = props.e; var $t = $(e.currentTarget); if ($t.data('paging-btn') != isUndefined) { this.pagingBtnClick(e); } else { if ($t.hasClass('btn_paging_first')) { this.pagingFirstClick(e); } else if ($t.hasClass('btn_paging_prev')) { this.pagingPrevClick(e); } else if ($t.hasClass('btn_paging_next')) { this.pagingNextClick(e); } else if ($t.hasClass('btn_paging_last')) { this.pagingLastClick(e); } else { this.pagingFirstClick(e); } } } else { this.makehtml.set.pagination({ page: this.opts.page, size: this.opts.size, totalCount: this.opts.total }); } window.EB.util.page.rerun({ target: $target }); this.buildTabState(); }, getParamUrl: function () { var r = []; var $panel = this.obj.closest('[data-tab-panel]'); if ($panel.length) { var tabId = $panel.attr('data-tab-panel'); var $tab = $('[data-tab="' + tabId + '"]'); if ($tab.length) { var tabInstance = $tab.data('Tab'); if (tabInstance != isUndefined) { var idx = tabInstance.opts.prevTab; r.push(idx); } } } r.push(this.obj.find('[data-paging-btn].active').data('value')); return win.EB.util.location.getParamUrl(this.params.pageName, r.join(',')); }, buildTabState: function () { var getParamUrl = this.getParamUrl(); win.history.replaceState({}, '', getParamUrl); }, setEvent: function (props) { // var response = props.response; // var $response = $(response); var $target = this.$target; this.params.scrollTo($target); // $target.empty().append($response); // var $totalEl = $target.find('[data-total]'); this.opts.total = props.total; this.opts.size = props.size; if (props.hasOwnProperty('page') && (props.page != null)) { this.opts.page = props.page; } // if ($totalEl.length) { // this.opts.total = $totalEl.eq(0).data('total'); // } else { // this.opts.total = 0; // } if (props.hasOwnProperty('e') && (props.e != null)) { var e = props.e; var $t = $(e.currentTarget); if ($t.data('paging-btn') != isUndefined) { this.pagingBtnClick(e); } else { if ($t.hasClass('btn_paging_first')) { this.pagingFirstClick(e); } else if ($t.hasClass('btn_paging_prev')) { this.pagingPrevClick(e); } else if ($t.hasClass('btn_paging_next')) { this.pagingNextClick(e); } else if ($t.hasClass('btn_paging_last')) { this.pagingLastClick(e); } } } else { this.makehtml.set.pagination({ page: this.opts.page, size: this.opts.size, totalCount: this.opts.total }); } window.EB.util.page.rerun({ target: $target }); } }; return Component; })(); return Component; })); (function (global, factory) { global = global; global.ePaginationMo = factory(); }(this, function () { 'use strict'; var Component = (function (isUndefined) { var win = window, $ = win.jQuery; function Component(container, args) { var defParams = { datas: {}, initialPause: false, itemNo: null, rangePage: 10, page: 1, size: 20, total: 0, on: { end: null } }; this.opts = gUtil.def(defParams, (args || {})); if (!(this.obj = $(container)).length) return; this.init(); }; Component.prototype = { init: function () { this.buildScroller(); this.obj.data('ePaginationMo', this); }, buildScroller: function () { var _this = this; gUtil.def(this, { scroller: { instance: null, destroy: function () { if (this.instance == null) return; this.instance.destroy(); this.instance = null; }, continue: function () { if (this.instance == null) return; this.instance.continue(); }, play: function () { if (this.instance == null) return; this.instance.play(); }, pause: function () { if (this.instance == null) return; this.instance.pause(); }, build: function () { if (this.instance != null) return; this.instance = new CmInfiniteScroll(_this.obj, { initialPause: _this.opts.initialPause, on: { end: function () { _this.outCallback('end'); } } }) } } }); this.scroller.build(); }, destroy: function () { this.scroller.destroy(); }, play: function () { this.scroller.play(); }, pause: function () { this.scroller.pause(); }, outCallback: function (ing) { var callbackObj = this.opts.on[ing]; if (callbackObj == null) return; callbackObj(); } }; return Component; })(); return Component; })); (function (global, factory) { global = global; global.TimeDealCountDown = factory(); }(this, function () { 'use strict'; var Component = (function (isUndefined) { var win = window, $ = win.jQuery; function Component (container, args) { if (!(this instanceof Component)) { return new Component(container, args); } var defParams = { renderCustom: function (timer) { return ''+timer.days+''+timer.hours+''+timer.minutes+''+timer.seconds+''; } }; this.opts = gUtil.def(defParams, (args || {})); if (!(this.obj = $(container)).length) return; this.init(); }; Component.prototype = { init: function () { this.setElements(); this.buildSwiper(); this.buildStartCheck(); }, setElements: function () { this.$el = this.obj; this.$slideWrap = this.obj.find('.swiper-container'); this.$slides = this.$el.find('.swiper-slide'); }, buildSwiper: function () { var activeIndex = (function () { var $slides = this.$slides; var _today = moment().format('YYYY-MM-DD'); var r = 0; var aEndDate = []; var build = function (i) { var $slide = $slides.eq(i); var $timeWrap = $slide.find('[data-time-wrap]'); var _endDate = $timeWrap.attr('data-time-wrap'); var _sEndDate = _endDate.split(' '); aEndDate.push(_sEndDate[0]); }; for (var i = 0, max = $slides.length; i < max; i++) { build(i); } if (aEndDate.indexOf(_today) != -1) { r = aEndDate.indexOf(_today); } else { aEndDate.push(_today); aEndDate.sort(); r = aEndDate.indexOf(_today); } return r; }.bind(this))(); this.timeSlider = new Swiper(this.$slideWrap, { slidesPerView: "auto", centeredSlides: true, speed: 600, initialSlide: activeIndex }); }, buildStartCheck: function () { var $slides = this.$slides; var getDiffTime = function (time) { var $new = moment(); var $end = time; var diff = moment.duration($new.diff($end)); var diffTime = { asDays: diff.asDays(), asHours: diff.asHours(), asMinutes: diff.asMinutes(), asSeconds: diff.asSeconds(), days: diff.days(), hours: diff.hours(), minutes: diff.minutes(), seconds: diff.seconds() }; diffTime.type = diffTime.asHours > 0 ? 'after' : 'before'; return diffTime; }; var build = function (i) { var $slide = $slides.eq(i); var $timeWrap = $slide.find('[data-time-wrap]'); var _startDate = $timeWrap.attr('data-start-date'); if (_startDate != isUndefined) { var diffTime = getDiffTime(_startDate); if (diffTime.type == 'after') { if ($slide.attr('data-countdown-loaded') == isUndefined) { this.buildCountdown($slide); $slide.attr('data-countdown-loaded', 'true'); } } else { $slide.trigger('TimeDealCountDown.wait'); } } }.bind(this); var remove = function () { $slides = $slides.not('[data-countdown-loaded]'); }; var run = function () { if ($slides.length) { for (var i = 0, max = $slides.length; i < max; i++) { build(i); } remove(); } else { window.clearInterval(this.time); } }.bind(this); window.clearInterval(this.time); this.time = window.setInterval(function () { run(); }, 1000); run(); }, buildCountdown: function ($slide) { var $timeWrap = $slide.find('[data-time-wrap]'); if ($timeWrap.length) { $timeWrap.on('CountDownStart', function () { $slide.trigger('TimeDealCountDown.start'); }); $timeWrap.on('CountDownEnd', function () { $slide.trigger('TimeDealCountDown.end'); }); var opts = { renderCustom: this.opts.renderCustom }; this.uicountdown = new FoUICountdown($timeWrap, opts); } }, destroy: function () { window.clearInterval(this.time); this.timeSlider.destroy(true, true); this.uicountdown.destroy(); } } return Component; })(); return Component; })); (function (global, factory) { global = global; global.mainNoticeLayer = factory(); }(this, function () { 'use strict'; var Component = (function (isUndefined) { var win = window, $ = win.jQuery, Util = { }, layerOpened = false; var ApiDomain = window.ApiDomain || {}; var Apis = { }; function Component (args) { if (!(this instanceof Component)) { return new Component(args); } Util = win.EB.util; ApiDomain = window.ApiDomain || {}; Apis = { prefix: { noticePopApi: ApiDomain.www + '/v1/notice-popup/api' } }; var defParams = { userCloseBtn: '[data-today-close]', cookieName: 'mainPopClose', width: null, height: null, appendContainer: null, stateAttr: { ajaxGet: null, focusin: false, destroy: false }, isKidiKidi: (function () { var r = false; if (win.UIPage && (win.UIPage.dispMallNo == '0000113')) { r = true; } return r; })(), isEMALL: (function () { var r = false; if (win.UIPage && (win.UIPage.dispMallNo == '0000014')) { r = true; } return r; })(), isPc: (function () { return $('html').hasClass('pc'); })(), classAttr: { focusin: 'focusin' }, customEvent: '.Component' + (new Date()).getTime() + Math.random() }; this.opts = Util.def(defParams, (args || {})); this.init(); }; Component.prototype = { init: function () { this.setElements(); this.buildParams(); this.buildLayout(); this.buildSlider(); this.buildLayer(); this.starttime = win.setTimeout(function () { var startUp = function () { if (!layerOpened) { layerOpened = true; this.opts.stateAttr.ajaxGet = eAjax.get({ url: Apis.prefix.noticePopApi }).done(function (response) { if (!this.opts.stateAttr.destroy) { if (response.resultCode == '200') { var datas = response.data; if (datas.list.length) { if (this.opts.appendContainer != null) { this.$body.css('display', ''); } this.layout.build({ datas: datas }); } } } }.bind(this)); } }.bind(this); // var getCookie = Util.cookie.get(this.opts.cookieName); // if (!getCookie.length) { // startUp(); // } var getStorage = Util.localStorage.get(this.opts.cookieName); if (getStorage != null) { var now = new Date().getTime(); var save = Number(getStorage); if (now >= save) { Util.localStorage.remove(this.opts.cookieName); startUp(); } } else { startUp(); } this.bindEvents(true); }.bind(this), 10); }, setElements: function () { this.$html = $('html'); if (this.opts.appendContainer != null && this.opts.appendContainer.length) { this.$body = this.opts.appendContainer; } else { this.$body = $('body'); } }, buildParams: function () { var _this = this; Util.def(this, { params: { isFloaingBanner: (function () { return !_this.opts.isPc && (_this.opts.isEMALL || _this.opts.isKidiKidi); })(), } }); }, buildLayout: function () { var _this = this; var classAttr = this.opts.classAttr; var isEMALL = this.opts.isEMALL; var isFloaingBanner = this.params.isFloaingBanner; Util.def(this, { layout: { loaded: false, viewport: 'mo', opts: { pc: { w: 640 }, mo: { w: 300 } }, getWrapper: function () { var layouts = []; if (isFloaingBanner) { layouts.push(''); } else { layouts.push('